<?php

namespace App\Http\Requests\Entity\Pm;

use App\Http\Requests\Request;

class PmtagRequest extends Request
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'name'       => 'required|max:100',
                        'title'      => 'required|max:100',
                        'short_desc' => 'required|max:100',
                        'status'     => 'required',
                        'online_at'  => 'date',
                        'offline_at' => 'date',
                        // 'images' => 'max:200'
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    // $id = $this->route('pmtags');
                    return [
                        'name'       => 'required|max:100',
                        'title'      => 'required|max:100',
                        'short_desc' => 'required|max:100',
                        'status'     => 'required',
                        'online_at'  => 'date',
                        'offline_at' => 'date',
                        // 'images' => 'max:200'
                    ];
                }
            default:
                break;
        }
    }

        /**
     *
     */
    public function messages()
    {
        return [
            'name.required'       => '名称 不能为空',
            'short_desc.required' => '简介 不能为空',
            'name.max'            => '名称 不能大于100个字符',
            'short_desc.max'      => '简介 不能大于100个字符',
            'title.required'       => '标题 不能为空',
            'status.required'     => '状态 不能为空',
            'online_at.date'  => '上线日期 不是一个有效的日期',
            'online_at.date'  => '下线日期 不是一个有效的日期',
        ];
    }
}
